package com.youhong.teethcare.settingpage;

import android.app.Activity;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.youhong.cuptime.blesdk.BleService;
import com.youhong.teethcare.MainActivity;
import com.youhong.teethcare.R;
import com.youhong.teethcare.dfu.DfuService;
import com.youhong.teethcare.netbeans.OtaHttpReturn;
import com.youhong.teethcare.utils.DialogUtil;
import com.youhong.teethcare.utils.HttpJsonUtils2;
import com.youhong.teethcare.utils.Tools;
import com.youhong.teethcare.utils.Util;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import no.nordicsemi.android.dfu.DfuProgressListener;
import no.nordicsemi.android.dfu.DfuProgressListenerAdapter;
import no.nordicsemi.android.dfu.DfuServiceInitiator;
import no.nordicsemi.android.dfu.DfuServiceListenerHelper;

public class DfuActivity extends Activity implements View.OnClickListener {

    ImageView iv_close;
    Button btn_updateNow;
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dfu);
        iv_close = findViewById(R.id.dfu_iv_close);
        iv_close.setOnClickListener(this);

        tv = findViewById(R.id.dfu_tv);

        btn_updateNow = findViewById(R.id.dfu_btn_upgrade);
        btn_updateNow.setOnClickListener(this);

        int newVersion = getIntent().getIntExtra("newVersion", 0);
        String str;
        if (newVersion >= 100) {

            str = newVersion / 100 + "." + newVersion / 10 + "." + newVersion % 10;

        } else {

            str = 0 + "." + newVersion / 10 + "." + newVersion % 10;

        }
     /*   tv.setText(getString(R.string.strings75) + "\nV" + str);*/
    }

    @Override
    public void onClick(View v) {

        if (v == iv_close) {

            this.finish();
        } else if (v == btn_updateNow) {

            setResult(Activity.RESULT_OK);
            this.finish();

        }

    }
}
